package cn.janescott.framework.dubbo;

import cn.janescott.framework.core.exception.MyException;

import java.util.Arrays;

import static cn.janescott.framework.dubbo.filter.MyExceptionFilter.HANDLED_EXCEPTION;
import static cn.janescott.framework.dubbo.filter.MyExceptionFilter.SEPARATOR;

/**
 * @author scott
 * @date 2019/2/25
 */
public class ExceptionFilterTester {

    public static void main(String[] args) throws Exception {
        MyException ex = new MyException("测试异常");
//        String errClass = ex.getClass().getName();
//        String errData = JsonUtils.toJson(ex);
//        String errMsg = null;
        String errClass = "";
        String errData = "";
        String errMsg = "";
        String msg = HANDLED_EXCEPTION + SEPARATOR + errClass + SEPARATOR + errData + SEPARATOR + errMsg;
        RuntimeException rt = new RuntimeException(msg);
        String message = rt.getMessage();
        System.out.println(message.split(SEPARATOR).length);
        Arrays.stream(message.split(SEPARATOR)).forEach(System.out::println);

//        LogisticException le = new LogisticException("物流企业代码不能为空");
//        String dMsg = JsonUtils.toJson(le);

        String dClass = "cn.janescott.framework.core.exception.MyException";

        Class<?> aClass = Class.forName(dClass);
//        Object fromJson = JsonUtils.fromJson(dMsg, aClass);
//        System.out.println(fromJson);
    }
}